package com.xiaomi.shwx.service.impl;

import com.xiaomi.shwx.common.enums.WorkOrderStatus;
import com.xiaomi.shwx.entity.pojo.WorkOrder;
import com.xiaomi.shwx.entity.request.AcceptOrderRequest;
import com.xiaomi.shwx.mapper.UserMapper;
import com.xiaomi.shwx.mapper.WorkOrderMapper;
import com.xiaomi.shwx.service.EngineerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class EngineerServiceImpl implements EngineerService {
    @Resource
    private WorkOrderMapper workOrderMapper;
    @Resource
    private UserMapper userMapper;
    @Override
    public WorkOrder getOrderDetails(String id) {
        return workOrderMapper.selectById(id);
    }

    @Override
    public Boolean acceptOrder(AcceptOrderRequest request) {
        WorkOrder workOrder = workOrderMapper.selectById(request.getOrderId());
        workOrder.setWorkOrderStatus(WorkOrderStatus.BE_CONFIRM);
        workOrder.setStatus(WorkOrderStatus.BE_CONFIRM.getStatus());
        workOrder.setEngineerId(Long.valueOf(request.getEngineerId()));
        workOrderMapper.updateById(workOrder);
        return true;
    }
}
